-
-
Notifications
You must be signed in to change notification settings - Fork 14.4k
THIR patterns: Explicitly distinguish &pin from plain &/&mut
#151282
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
Some changes occurred in match checking cc @Nadrieril Some changes occurred in exhaustiveness checking cc @Nadrieril Some changes occurred in match lowering cc @Nadrieril |
|
|
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
I'll probably need to rebase this again after #151295. |
This comment has been minimized.
This comment has been minimized.
|
This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed. Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers. |
|
Big fan of this. The fact that this uncovered a bug is enough proof that we need this, if we needed any. @bors r+ |
Rollup merge of #151282 - Zalathar:pin-pat, r=Nadrieril THIR patterns: Explicitly distinguish `&pin` from plain `&`/`&mut` Currently, `thir::PatKind::Deref` is used for ordinary `&`/`&mut` patterns, and also for `&pin const` and `&pin mut` patterns under `feature(pin_ergonomics)`. The only way to distinguish between them is by inspecting the `Ty` attached to the pattern node. That's non-obvious, making it easy to miss, and is also a bit confusing to read when it does occur. This PR therefore adds an explicit `pin: hir::Pinnedness` field to `thir::PatKind::Deref`, to explicitly distinguish pin-deref nodes from ordinary builtin-deref nodes. (I'm not deeply familiar with the future of pin-patterns, so I'm not sure whether that information is best carried as a field or as a separate `PatKind`, but I think this approach is at least an improvement over the status quo.) r? Nadrieril (or compiler)
Rollup of 4 pull requests Successful merges: - rust-lang/rust#149174 (`const` blocks as a `mod` item) - rust-lang/rust#151282 (THIR patterns: Explicitly distinguish `&pin` from plain `&`/`&mut`) - rust-lang/rust#151593 (miri subtree update) - rust-lang/rust#151516 (Do not emit errors on non-metaitem diagnostic attr input) r? @ghost
…iaskrgr Rollup of 4 pull requests Successful merges: - rust-lang#149174 (`const` blocks as a `mod` item) - rust-lang#151282 (THIR patterns: Explicitly distinguish `&pin` from plain `&`/`&mut`) - rust-lang#151593 (miri subtree update) - rust-lang#151516 (Do not emit errors on non-metaitem diagnostic attr input) r? @ghost
Currently,
thir::PatKind::Derefis used for ordinary&/&mutpatterns, and also for&pin constand&pin mutpatterns underfeature(pin_ergonomics). The only way to distinguish between them is by inspecting theTyattached to the pattern node.That's non-obvious, making it easy to miss, and is also a bit confusing to read when it does occur.
This PR therefore adds an explicit
pin: hir::Pinnednessfield tothir::PatKind::Deref, to explicitly distinguish pin-deref nodes from ordinary builtin-deref nodes.(I'm not deeply familiar with the future of pin-patterns, so I'm not sure whether that information is best carried as a field or as a separate
PatKind, but I think this approach is at least an improvement over the status quo.)r? Nadrieril (or compiler)